const db = require('../middleware/db');
const config = require('../../config/config');//引入配置文件
class MysqlModules {
    /**
     * @param {*} sql 
     * @param {*} value 
     */
    static async select(table, content = [], where = '', value = []) {
        let sql = content.length ? `select ${content.join(',')}` : 'select *';
        sql += ` from ${config.mysql.prefix}${table} `;
        if (where) {
            sql += where;
        }
        let data = [];
        await db.query(sql, value).then(function (result) {
            data = result;
        }).catch(function (error) {
            console.log(error);
        });
        return data;
    }
}
module.exports = MysqlModules;